package com.teamclub.erp.scontrollers

import com.teamclub.app.sforms.AppSubjectUserForm
import com.teamclub.domain.system.AppSubjectUser
import com.teamclub.erp.sforms.LoginForm
import com.teamclub.erp.sservices.ErpLoginService
import com.teamclub.util.libs.Eithers
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.{PostMapping, RequestBody, RequestMapping, RestController}

@RestController("com.teamclub.erp.scontrollers.ErpLoginController")
@RequestMapping(Array("/erp/login"))
class ErpLoginController {
  @Autowired
  var loginService: ErpLoginService = _

  @PostMapping(Array("modifyPwd"))
  def modifyPwd(@RequestBody form: LoginForm) = {
    Eithers.toJson(loginService.modifyPwd(form))
  }
  @PostMapping(Array("/"))
  def login(@RequestBody form: AppSubjectUserForm) = {
    Eithers.toJson(loginService.login(form))
  }
}
